//
//  JSTInterestcircleFrame.m
//  KYKJPackDemo
//
//  Created by 01 on 17/5/10.
//  Copyright © 2017年 ???. All rights reserved.
//

#import "JSTInterestcircleFrame.h"
#import "JSTInterestcircleDataModel.h"
#import "JSTInterestcircleFootFrame.h"
#import "JSTInterestcircleContentFrame.h"
#import "JSTInterestcircleImageFrame.h"

@implementation JSTInterestcircleFrame

- (void)setModel:(JSTInterestcircleDataModel *)model
{
    _model = model;
    //
    JSTInterestcircleContentFrame *contentFrame = [[JSTInterestcircleContentFrame alloc] init];
    contentFrame.model = model;
    self.contentFrame = contentFrame;
    
    //
    JSTInterestcircleImageFrame *imageFrame = [[JSTInterestcircleImageFrame alloc] init];
    imageFrame.model = model;
    self.imageFrame = imageFrame;
    
    //
    JSTInterestcircleFootFrame *footFrame = [[JSTInterestcircleFootFrame alloc] init];
    footFrame.model = model;
    self.footFrame = footFrame;
    
    if (!IsArrEmpty(model.contentImgUrlArr))
    {
        CGRect newImageFrame = imageFrame.frame;
        newImageFrame.origin.y = CGRectGetMaxY(contentFrame.frame) + 10.;
        imageFrame.frame = newImageFrame;
        
        CGRect newFootFrame = footFrame.frame;
        newFootFrame.origin.y = CGRectGetMaxY(imageFrame.frame) + 10.;
        footFrame.frame = newFootFrame;
    }else
    {
        CGRect newFootFrame = footFrame.frame;
        newFootFrame.origin.y = CGRectGetMaxY(contentFrame.frame);
        footFrame.frame = newFootFrame;
    }
    //
    CGFloat x = 0;
    CGFloat h = CGRectGetMaxY(footFrame.frame);
    CGFloat y = 0;
    CGFloat w = kDeviceWidth;
    self.frame = CGRectMake(x, y, w, h);
}

@end
